package com.qidian.mes.md.controller;

import com.qidian.mes.md.service.CustomerService;
import com.qidian.mes.pojo.MdCustomer;
import com.qidian.mes.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 小可怎么都睡不够
 * @Description:
 * @Time: 2024-04-09 20:42
 **/

@RestController
@RequestMapping("/customer")
@CrossOrigin
public class CustomerController {
    @Autowired
    private CustomerService customerService;

    @RequestMapping("/query/{page}/{limit}")
    public QdResult getCustomers(@RequestParam String keyWord, @PathVariable Integer page, @PathVariable Integer limit) {
        return customerService.getCustomers(keyWord, page, limit);
    }

    @GetMapping("/query/{id}")

    public QdResult getCustomerById(@PathVariable Long id) {
        return customerService.getCustomerById(id);
    }

    @PostMapping("/add")
    public QdResult insertCustomer(@RequestBody MdCustomer customer) {
        return customerService.insertCustomer(customer);
    }

    @PutMapping("/update")
    public QdResult updateCustomer(@RequestBody MdCustomer customer) {
        return customerService.updateCustomer(customer);
    }


    @DeleteMapping("/{id}/{status}")
    public QdResult updateUserStatus(@PathVariable Long id, @PathVariable Integer status) {
        return customerService.updateUserStatus(id, status);
    }

    @GetMapping("/count")
    public QdResult getCount(){
        return customerService.getCount();
    }
}

